package cn.hu.basic.commonenum;

/** 系统错误码 **/
public enum ErrorCode {

    SYSTEM_ERROR("1001","系统内部异常"),
    PAGE_ERROR("1002","分页错误"),
    PASSWORD_CHECK_FAILED("1003","密码不一致"),
    SHOP_ALREADY_EXIST("1004","店铺已存在"),
    CONTENT_AUDIT_FAILED("1005","AI审核不合规"),
    LOGO_AUDIT_FAILED("1006","AI审核不合规"),
    IMAGE_CODE_TIME_OUT("1008","图形验证码过期"),
    IMAGE_CODE_ERROR("1009","图形验证码错误"),
    USER_ALREADY_EXIST("1010","用户已存在"),
    SMS_EXPIRED("1011","短信验证码过期"),
    SMS_FAILED("1012","短信验证码错误"),
    LOGIN_FAILED("1013","账号或密码错误"),
    WECHAT_LOGIN_FAILED("1014","微信登录接口异常"),
    LOGININFO_FAILED("1015","用户登录信息异常"),
    ORDER_PROCESS("1016","此订单正在进行中,请勿重复接单"),
    PET_SOLD_OUT("1017","你领养的宠物已下架"),
    SHOPADMIN_ALREADYEXSIT("1007","店长已存在");
    //错误码
    private String code;
    //错误信息
    private String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }
    public String getMessage() {
        return message+"["+code+"]";
    }

    public static ErrorCode getByCode(String code){
        //获取ErrorCode中所有对象的数组
        ErrorCode[] errorCodes = ErrorCode.values();

        for (ErrorCode errorCode : errorCodes) {
            if(errorCode.getCode().equals(code)){
                return errorCode;
            }
        }
        return null;
    }
}